package com.ssm.controller;

import com.ssm.domain.Account;
import com.ssm.domain.User;
import com.ssm.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author zy9524
 * @company SocialistSuccessor
 * @date 2019/6/10 9:28
 */
@Controller
public class AccountController {
    @Autowired
    private AccountService accountService;

    @RequestMapping("/findAllAccount")
    public ModelAndView findAllAccount(ModelAndView modelAndView) {
        List<Account> accountList = accountService.findAllAccount();
        modelAndView.addObject("accountList", accountList);
        modelAndView.setViewName("list");
        return modelAndView;
    }

    @RequestMapping("/findAllUser")
    public ModelAndView findAllUser(ModelAndView modelAndView) {
        List<User> userList = accountService.findAllUser();
        System.out.println(userList);
        System.out.println(userList.get(0).getRoleList());
        modelAndView.addObject("userList", userList);
        modelAndView.setViewName("userList");
        return modelAndView;
    }
}
